//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    loading:0,
    disabled:0
  },
  //事件处理函数
  
  onLoad: function () {
   
  },
  onShow: function (options) {
    console.log(app.globalData.extraData);
    if (app.globalData.extraData ){
      app.alert(app.globalData.extraData.msg);
    }
    this.setData({ loading: 0, disabled: 0 });

  },
  changmoney: function (e) {
    this.data.order_amount = e.detail.value;
  },
  formSubmit: function () {
    var that = this;
    if (!this.data.order_amount > 0) {
      app.alert("请输入金额!");
      return false;
    }
    that.setData({ loading: 1, disabled: 1 });
    var shop_no = "20191024308978649d";
    var outTradeNo = shop_no + Date.parse(new Date());
    // outTradeNo ="20191024308978649d20190602"
    // app.alert(outTradeNo);
    // return false;
    wx.navigateToMiniProgram({
      appId: 'wx113f2407af0ed4da',
      path: 'pages/pay/index',
      extraData: {
        "shop_no": shop_no,
        "secret": "wD7Ct61VJePUad1KyA2Iz5EYKLO2b8",
        "totalAmount": this.data.order_amount*100,
        "outTradeNo": outTradeNo,
        "NonceStr": Date.parse(new Date()),
      },
      envVersion: 'release',
      success(res) {
        // 打开成功
      }
    })
    

  },

})
